<%@page import="org.smartercontext.remotedeployable.UserPreferences"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript" src="Geolocation/Geolocation.js"></script>
<title>Test the components</title>
</head>
<body>
<div style="text-align: center;">
<h1>SmarterContext components on any online store retailer</h1>
<h3>Send my location to SmarterContext</h3>
<input type="button" onclick="localeMe();" value="Locate me">
<h3>Send my preferences</h3>
<%
String username = (String)session.getAttribute("username");
UserPreferences usp=new UserPreferences(username);
usp.chargeTestData();
session.setAttribute("userpreferences", usp.getInfoAtJSONformat());
%>
<input type="button" onclick="sendPref();" value="Send my preferences">
<hr>
<h1>Example of third party consumer application</h1>
<h3>Check user's information -- Consumer service</h3>

<form action="ServletConsume" target="_blank">
<p>Username: <input type="text" name="usernameSearch"></p>
<p><select name="format">
<option value="json">JSON</option>
<option value="rdfxml">RDF/XML</option>
</select></p>
<input type="submit" value="Query now"> 
</form>

<hr>
<h1>Watch the WSDL implementation</h1>
<a href="http://smartercontext.org:8080/SmarterContext_Web_Server/services/Communication_Impl?wsdl" target="_blank">Watch</a>

<%
if(request.getQueryString()!=null){
	if(request.getParameter("Error")!=null){
		String typeE = request.getParameter("Error");
		
		if(typeE.equals("1")){
			out.println("<p style=\"color: red\">Unknown error</p>");
		}else if(typeE.equals("2")){
			out.println("<p style=\"color: red\">Unknown error</p>");
		}
		
	}else if(request.getParameter("Success")!=null){
		String typeS = request.getParameter("Success");
		
		if(typeS.equals("Location")){
			out.println("<p style=\"color: blue\">Coordinates sent</p>");
		}else if(typeS.equals("Prefs")){
			out.println("<p style=\"color: blue\">Preferences sent</p>");
		}
	}
}

%>
</div>
<script type="text/javascript">
	
	function localeMe(){
		
		getLocation();
	}
	
	function sendPref(){
		location.href="ServletBuyerPreferences";
	}

</script>
</body>
</html>